import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class ConnectDb
{

    // ........................ D A T A F I E L D S ............................//
    // ............. G L O B A L P R I V A T E C O N S T A N T S .............//
    private final String DRIVER = "oracle.jdbc.driver.OracleDriver";
    private final String URL = "jdbc:oracle:thin:@localhost:1521:oraDB";
    private final String ID = "scott";
    private final String PW = "tiger";
    // ................. G L O B A L P R I V A T E V A R S ...................//
    /** hold a pointer to the database connection. */
    private Connection connect;
    // ........................ C O N S T R U C T O R S ..........................//
    public ConnectDb()
    {
    try {
    Class.forName(DRIVER);
    connect = DriverManager.getConnection(URL, ID, PW);
    } catch (SQLException ex) {
    System.err.println(ex.getMessage());
    } catch (ClassNotFoundException ex) {
    System.err.println(ex.getMessage());
    }
    } //constructor
    //.............................. G E T T E R S ...............................//
    /** get the database connection object. */
    public Connection getDBConnection()
    { return this.connect; } // method
    // ...................... P U B L I C M E T H O D S ........................//
    /** disconnect from the database. */
    public void disconnectFromDB() {
    try {
    connect.close();
    } catch (SQLException e) {
    System.err.println(e.getMessage());
    }
    } // method
    }

